package com.demo.validate;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 邮箱校验
 *
 * @author sdyang
 * @create 2019-01-22 8:57
 **/
public class EmailValidate extends FieldDataValidate {

    @Override
    public boolean check(Object object) {
        if (object == null)
            return false;
        String regEx1 = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
        Pattern p = Pattern.compile(regEx1);
        Matcher m = p.matcher(object.toString());
        if (m.matches()) {
            return true;
        } else {
            return false;
        }
    }
}
